<?php
/**
 * Description of modifier
 *
 * @author Alen
 * @since 1.0.0 2013-12-2
 */
    //put your code here
function smarty_modifier_cntime($old_time) { 
    $res    = null; 
    $old    = strtotime($old_time); 
    $now    = $_SERVER['REQUEST_TIME']; 
    $ex    = $now - $old; 
    switch ($ex) { 
        case $ex < 60 : 
            $res    = '刚才'; 
            break; 
        case $ex < 3600 : 
            $res    = intval($ex/60).'分钟前'; 
            break; 
        case $ex < 86400 : 
            $res    = intval($ex/3600).'小时前'; 
            break; 
        case $ex < 604800 : 
            $res    = intval($ex/86400).'天前'; 
            break; 
        default : 
            $res    = date("Y-m-d H:s",$old); 
    } 
    return $res; 
} 

?>
